import {defineStore} from 'pinia'
import {ref} from 'vue'
import {RouteLocationNormalized} from 'vue-router'

export const useThemeConfig = defineStore('themeConfig', () => {
    const isCollapse = ref(true)
    const historicalRouting =ref<RouteLocationNormalized[]>([])
    const  changeIsCollapse=()=>{
        isCollapse.value = !isCollapse.value
    }
    const setHistoryRoute = (route:RouteLocationNormalized) =>{
        if(!historicalRouting.value.find(item=>item.name===route.name)){
         historicalRouting.value.push(route)
            console.log(historicalRouting.value)
        }
    }
    const removeHistoryRoute = (route: string) => {
        console.log(route, 'route')
        historicalRouting.value.splice(historicalRouting.value.findIndex(item=>item.name===route),1)
    }
    return {isCollapse,changeIsCollapse,setHistoryRoute, historicalRouting,removeHistoryRoute}
}, {
    persist: true
})
